package cn.btks.resultintegration.rule.service.impl;

import cn.btks.resultintegration.rule.pojo.ProjectCategory;
import cn.btks.resultintegration.rule.repository.ProjectCategoryRepository;
import cn.btks.resultintegration.rule.service.ProjectCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author lijun
 * @Date 2021/2/19 10:49
 */
@Service
public class ProjectCategoryServiceImpl implements ProjectCategoryService {

    @Autowired
    ProjectCategoryRepository projectCategoryRepository;

    @Override
    public ProjectCategory findById(Long id) {
        Optional<ProjectCategory> optional = projectCategoryRepository.findById(id);
        if(optional.isPresent()){
            return optional.get();
        }
        return null;
    }

    @Override
    public List<ProjectCategory> findAllProjectCategory() {
        return projectCategoryRepository.findAll();
    }

    @Override
    public List<ProjectCategory> findAllByCategorySecondId(Long categorySecondId) {
        return projectCategoryRepository.findAllByCategorySecondId(categorySecondId);
    }
}
